{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Single-phase flow and heat exchange\n",
    "\n",
    "The aim  is to present the mathematical equations for single-phase fluid flow\n",
    "in a porous medium coupled with heat exchange between the liquid and the surrounding\n",
    "rock matrix.\n",
    "\n",
    "## Working hypotheses\n",
    "\n",
    "Let us suppose that the maximum reservoir depth is $z_{\\max} \\sim 5km$,\n",
    "considering an approximate geothermal gradient of $25 ^\\circ C \\cdot km^{-1}$ the\n",
    "maximum temperature reached at the bottom boundary is around $150^\\circ C$. We\n",
    "assume the range of temperature is $[10 ^\\circ C, 150 ^\\circ C]$.\n",
    "Moreover, roughly speaking, the idrostatic pressure gradient\n",
    "is $10 MPa \\cdot km^{-1}$ obtaining a maximum of pressure at the bottom of the\n",
    "reservoir of $50 MPa$.\n",
    "<img src=\"./fig/water_phase_diagram_2.gif\" width=\"45%\">\n",
    "At these condition, from the water-phase diagram reported in the previous Figure, \n",
    "the can assume that the water is only in the liquid state.\n",
    "We assume also that the water does not react with the rock matrix and only an\n",
    "heat exchange takes place, instantaneously with respect the typical time scale\n",
    "of the simulation, between the water and the surrounding medium.\n",
    "\n",
    "## Physical equations\n",
    "\n",
    "Let us assume that the water is only present in the liquid phase and\n",
    "the rock matrix is inert and at rest. Our objective is to compute the Darcy\n",
    "velocity $\\mathbf{u}$ $[m \\cdot s^{-1}]$, the pressure $p$ $[Pa]$ and the temperature\n",
    "$T$ $[^\\circ C]$ such that: the Darcy problem is satisfied\n",
    "\\begin{gather}\n",
    "    \\begin{cases}\n",
    "        \\nabla \\cdot \\left( \\rho_w \\mathbf{u} \\right) = -\\phi \\dfrac{\\partial\n",
    "        \\rho_w}{\\partial t} \\\\\n",
    "        \\mathbf{u} = - \\dfrac{K}{\\mu} \\left( \\nabla p - \\rho_w g \\mathbf{e}_3 \\right)\n",
    "    \\end{cases},\n",
    "\\end{gather}\n",
    "coupled with the thermal conduction and convection equation\n",
    "\\begin{gather} \\label{eq:complete_thermal}\n",
    "    c_e \\dfrac{\\partial T}{\\partial t} + \\rho_w\n",
    "    c_w \\mathbf{u} \\cdot \\nabla T = \\nabla \\cdot \\Lambda_e \\nabla T.\n",
    "\\end{gather}\n",
    "In the previous equation the effective thermal capacity\n",
    "$c_e$ $[J \\cdot m^{-2} \\cdot K^{-1}]$ is defined as the weighted averaged\n",
    "between the water $c_w$ and solid $c_s$ specific thermal capacity, namely\n",
    "\\begin{gather}\\label{eq:effective_capacty}\n",
    "    c_e = \\phi \\rho_w c_w + \\left(1-\\phi\\right) \\rho_s c_s.\n",
    "\\end{gather}                                                                     \n",
    "The data in the system are\n",
    "* porosity $\\phi$ $[\\cdot]$ of the rock matrix;                                    \n",
    "* density of rock matrix $\\rho_s$ and water $\\rho_w$ both $[kg \\cdot m^{-3}]$;\n",
    "* absolute permeability of the rock matrix $K$ $[m^2]$;\n",
    "* dynamic viscosity $\\mu$ $[Pa \\cdot s]$ of water;\n",
    "* modulus of gravity acceleration $g$ $[m \\cdot s^{-2}]$ equal to $9.81 m \\cdot s^{-2}$;\n",
    "* specific heat capacity of water $c_w$ and solid $c_s$ both $[J \\cdot kg^{-1} \\cdot K^{-1}]$;\n",
    "* effective thermal conductivity $\\Lambda_e$ measured in $[W \\cdot m^{-1} \\cdot K^{-1}]$.\n",
    "\n",
    "## Density\n",
    "\n",
    "In this part we present empirical laws and relation among the density, water and solid rock, and the unknown of the flow.\n",
    "The authors in [Somerton 1992](#Somerton1992) and Waples2004 [Waples 2004](#Waples2004) discuss an empirical law of\n",
    "the density of the water related on the temperature, they propose the following\n",
    "\\begin{gather}\n",
    "    \\rho_w = \\dfrac{\\rho_w(T_0)}{1+\\eta_w\\left( T - T_0 \\right)},\n",
    "\\end{gather}\n",
    "where $\\rho_w(T_0)$ is the density at a specific temperature value and $\\eta$\n",
    "$[\\cdot]$ is the coefficient of the thermal expansion. For example at $T_0 =\n",
    "10 ^\\circ C$ we get $\\rho_w(T_0) = 999.8349 kg \\cdot m^{-3}$. The coefficient of\n",
    "the thermal expansion for the water can be evaluated using\n",
    "\\begin{gather*}\n",
    "    \\eta_w = 0.0002115 + 1.32 \\cdot 10^{-6} T + 1.09 \\cdot 10^{-8} T^2.\n",
    "\\end{gather*}\n",
    "The following Figure depicts the value of $\\eta_w$ in terms of the temperature.\n",
    "<img src=\"./fig/thermal_expansion.png\" width=\"45%\">\n",
    "If the variation of the temperature is not severe, it is possible to approximate the previous\n",
    "relation by the first order Taylor expansion obtaining\n",
    "\\begin{gather}\n",
    "    \\rho_w = \\rho_w(T_0) \\left[ 1 - \\eta_w\\left( T - T_0 \\right) \\right].\n",
    "\\end{gather}\n",
    "This expression is considered, for example, in [Bear 1972](#Bear1972).\n",
    "The next Figure presents a comparison between these two expressions of the water densisyt \n",
    "for our range of temperature.\n",
    "<img src=\"./fig/density.png\" width=\"45%\">\n",
    "We observe that the two expressions are in good agreement for values less than $100^\\circ C$ and\n",
    "a maximum error of $0.84\\%$ at $150^\\circ C$.\n",
    "\n",
    "## Thermal conductivity\n",
    "\n",
    "In this part we present a mathematical model to describe the effective thermal\n",
    "conductivity $\\Lambda_e$ introduced in the heat equation.\n",
    "Let us assume that $\\Lambda_e$ is an isotropic tensor such that $\\Lambda_e =\n",
    "\\lambda_e I$, with $\\lambda_e$ $[W \\cdot m^{-1} \\cdot K^{-1}]$ a scalar value.  Since it\n",
    "represents a combination between the water $\\lambda_w$ $[W \\cdot m^{-1}  \\cdot K^{-1}]$ and\n",
    "solid $\\lambda_s$ $[W \\cdot m^{-1} \\cdot K^{-1}]$ thermal conductivity,\n",
    "following [Schon 2011](#Schon2011) we consider $\\lambda_e$\n",
    "defined through the weighted geometric average of both\n",
    "\\begin{gather*}\n",
    "    \\lambda_e = \\lambda_w^\\phi \\lambda_s^{1-\\phi}.\n",
    "\\end{gather*}\n",
    "In the previous relation the solid is considered as a unique phase, for this\n",
    "reason to accommodate heterogeneous rock matrix composed by $N_s$ of different\n",
    "rocks, the solid head conductivity can be expressed using\n",
    "\\begin{gather*} %\\label{eq:solidConductivity}\n",
    "    \\lambda_s = \\dfrac{1}{V_s^t} \\sum_{i=1}^{N_s} V_s^i \\lambda^i_s\n",
    "    \\quad \\text{with} \\quad\n",
    "    V_s^t = \\sum_{i=1}^{N_s} V_s^i\n",
    "\\end{gather*}\n",
    "where $V_s^i/V_s^t$ $[\\cdot]$ is the fraction of a specific rock type $i$ in a\n",
    "control volume and $\\lambda^i_s$ $[W \\cdot m^{-1} \\cdot K^{-1}]$ is the head\n",
    "conductivity of the rock $i$. For most rock types, the head conductivity\n",
    "decreases with increasing temperature, and can be a function of the pressure $p$\n",
    "and temperature $T$\n",
    "\\begin{gather*}\n",
    "    \\lambda_s^i = \\lambda_s^i(T_0) \\dfrac{1+\\alpha_0^i p}{1 + c_0^i T},\n",
    "\\end{gather*}\n",
    "where $\\lambda_s^i(T_0)$ $[W \\cdot m^{-1} \\cdot K^{-1}]$ is a reference heat\n",
    "conductivity at $T_0$, $c_0^i$ $[K^{-1}]$ and $\\alpha_0^i$ $[Pa^{-1}]$ are\n",
    "rock dependent parameters.  In [Griffiths 1992](#Griffiths1992) and in [Schon 2011](#Schon2011)\n",
    "Subsubsection 9.2.2, the authors derived an empirical relationship for thermal\n",
    "conductivity of water $\\lambda_w$\n",
    "\\begin{gather*}\n",
    "    \\lambda_w = 0.56 + 0.002 T- 1.01 \\cdot 10^{-5} T^2 +\n",
    "    6.71 \\cdot 10^{-9} T^3,\n",
    "\\end{gather*}\n",
    "Moreover the influence of pressure on thermal conductivity of the water is relatively\n",
    "small compared with the influence of temperature. The dependence of $\\lambda_w$ from $T$ is depicted in \n",
    "the next Figure.\n",
    "<img src=\"./fig/thermal_conductivity.png\" width=\"45%\">\n",
    "\n",
    "## Specific heat capacity\n",
    "Let us consider the specific heat capacity of the rock matrix $c_s$ first. Since\n",
    "the underground is heterogeneous, for a control volume composed by $N_s$ of\n",
    "different rocks, we can define the specific heat capacity $c_s^i$ $[J \\cdot\n",
    "kg^{-1} \\cdot K^{-1}]$ for each of them. Moreover, in our model, only one single value is considered we average\n",
    "the specific heat capacity for all the rocks according to their mass $\\rho_s^i\n",
    "V_s^i$ in the reference volume\n",
    "\\begin{gather*}\n",
    "    c_s = \\dfrac{1}{m_s^t} \\sum_{i=1}^{N_s} c_s^i \\rho_s^i V_s^i\n",
    "    \\quad \\text{with} \\quad\n",
    "    m_s^t = \\sum_{i=1}^{N_s} \\rho_s^i V_s^i.\n",
    "\\end{gather*}\n",
    "We assume that the rock matrix is incompressible such that the specific heat\n",
    "capacity at constant pressure is equal to the specific heat capacity at constant\n",
    "volume. This assumption gives us the independence from the pressure, however\n",
    "$c_s^i$ depends on the temperature in a linear way. Following\n",
    "[Eppelbaum 2014](#Eppelbaum2014) Subsection 2.2 we obtain\n",
    "\\begin{gather*}\n",
    "    c_s^i = c_s^i(T_0) + \\zeta \\left( T - T_0 \\right),\n",
    "\\end{gather*}\n",
    "where $T_0$ is the initial temperature and $\\zeta$ $[J \\cdot kg^{-1} \\cdot\n",
    "K^{-2}]$ is a rock dependent coefficient. For example are reported in the following Table.\n",
    "\n",
    "| rock type |  $c_s$ at $10 ^\\circ C$ | $c_s$ at $150 ^\\circ C$ | $\\zeta$               |\n",
    "|-----------|---------------------|---------------------|-----------------------|\n",
    "| sandstone | 823.82              | 834.06              | 8.9 1e-2              |\n",
    "| shale     | 794.37              | 808.73              | 10.26 1e-2            |\n",
    "| siltstone | 849.02              | 860.27              | 8.04 1e-2             |\n",
    "\n",
    "An empirical relation for the water specific heat capacity $c_w$ is proposed in\n",
    "[Waples 2004](#Waples2004), which is valid for values of temperature between\n",
    "$20^\\circ C - 290^\\circ C$ and is\n",
    "\\begin{gather}\n",
    "    c_w = \\dfrac{4245 - 1.841 T}{\\rho_w}\n",
    "\\end{gather}\n",
    "where $\\rho_w$ is computed using one of the previous model.\n",
    "The previous equation can be extrapolated down to\n",
    "$10 ^\\circ C$ without significant error, and thus can be used for the temperature\n",
    "interval we have assumed. The following Figure\n",
    "shows the value of $c_w$ for different values of temperature.\n",
    "<img src=\"./fig/specific_heat_capacity_water.png\" width=\"45%\">\n",
    "As long as the pressure is high enough to keep the\n",
    "water in a liquid phase as it is in our case, the specific heat capacity of\n",
    "water under subsurface conditions can be estimated with good accuracy, without including pressure dependence.\n",
    "\n",
    "## Dynamic viscosity\n",
    "\n",
    "The dynamic viscosity of water is highly temperature dependent\n",
    "\\begin{gather}\n",
    "    \\mu = \\mu_0 10^{ \\delta / \\left(T - 140 \\right)}\n",
    "\\end{gather}\n",
    "with $\\mu_0 = 2.414 \\cdot 10^{-5} Pa \\cdot s$ and $\\delta = 247.8$.\n",
    "\n",
    "## References\n",
    "* <a name=\"Somerton1992\"></a>[Somerton 1992]  Somerton, W. H. Thermal Properties and Temperature-Related Behavior of Rock/Fluid Systems Elsevier Science, 1992\n",
    "* <a name=\"Waples2004\"></a>[Waples 2004] Waples, D. W. & Waples, J. S. A Review and Evaluation of Specific Heat Capacities of Rocks, Minerals, and Subsurface Fluids. Part 2: Fluids and Porous Rocks Natural Resources Research, Kluwer Academic Publishers-Plenum Publishers, 2004, 13, 123-130\n",
    "* <a name=\"Bear1972\"></a>[Bear 1972] Bear, J. Dynamics of Fluids in Porous Media American Elsevier, 1972\n",
    "* <a name=\"Schon2011\"></a>[Schon 2011] Schön, J. H. Physical Properties of Rocks Physical Properties of Rocks A Workbook, Elsevier, 2011, 8, i -\n",
    "* <a name=\"Griffiths1992\"></a>[Griffiths 1992] Griffiths, C. M.; Brereton, N. R.; Beausillon, R. & Castillo, D. Thermal conductivity prediction from petrophysical data: a case study Geological Society, London, Special Publications, 1992, 65, 299-315\n",
    "* <a name=\"Eppelbaum2014\"></a>[Eppelbaum 2014] Eppelbaum, L.; Kutasov, I. & Pilchin, A. Applied Geothermics Springer-Verlag Berlin Heidelberg, 2014"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Edit Metadata",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
